﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using Data.ModelDatabase;

namespace Data.Mappers
{
    public class ProductMapper : IMapper<Entity.Products.Product, Product>
    {
        public Entity.Products.Product WrapperData(Product product)
        {
            Mapper.CreateMap<Category, Entity.Categories.Category>();
            Mapper.CreateMap<Product, Entity.Products.Product>();
            Mapper.CreateMap<OrderPosition, Entity.Orders.OrderPosition>();
            Mapper.CreateMap<Basket, Entity.Baskets.Basket>();

            return Mapper.Map<Product, Entity.Products.Product>(product);
        }

        public List<Entity.Products.Product> WrapperData(List<Product> products)
        {
            Mapper.CreateMap<Category, Entity.Categories.Category>();
            Mapper.CreateMap<Product, Entity.Products.Product>();
            Mapper.CreateMap<OrderPosition, Entity.Orders.OrderPosition>();
            Mapper.CreateMap<Basket, Entity.Baskets.Basket>();
            Mapper.CreateMap<User, Entity.Users.User>();

            return Mapper.Map<List<Product>, List<Entity.Products.Product>>(products);
        }

        public Product WrapperEntity(Entity.Products.Product product)
        {
            Mapper.CreateMap<Entity.Categories.Category, Category>();
            Mapper.CreateMap<Entity.Products.Product, Product>();
            Mapper.CreateMap<OrderPosition, Entity.Orders.OrderPosition>();

            return Mapper.Map<Entity.Products.Product, Product>(product);
        }

        public List<Product> WrapperEntity(List<Entity.Products.Product> products)
        {
            Mapper.CreateMap<Entity.Categories.Category, Category>();
            Mapper.CreateMap<Entity.Products.Product, Product>();

            return Mapper.Map<List<Entity.Products.Product>, List<Product>>(products);
        }
    }

}
